<!DOCTYPE html>
<html lang="zh-CN">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>注册 - I投E行</title>
    <link href="favicon.ico" rel="icon">
    <link rel="stylesheet" href="css/style.css">
</head>
<body class="auth-page">
    <div class="auth-container">
        <div class="auth-card">
            <div class="auth-header">
                <h1>注册 I投E行</h1>
                <p>开始您的投资行为改善之旅</p>
            </div>
            <form id="registerForm" class="auth-form">
                <div class="form-group">
                    <label for="regUsername">用户名</label>
                    <input type="text" id="regUsername" name="username" required>
                </div>
                <div class="form-group">
                    <label for="regEmail">电子邮箱</label>
                    <input type="email" id="regEmail" name="email" required>
                </div>
                <div class="form-group">
                    <label for="regPassword">密码</label>
                    <input type="password" id="regPassword" name="password" required>
                </div>
                <div class="form-group">
                    <label for="regConfirmPassword">确认密码</label>
                    <input type="password" id="regConfirmPassword" name="confirmPassword" required>
                </div>
                <div class="form-group">
                    <label for="riskProfile">风险偏好</label>
                    <select id="riskProfile" name="riskProfile">
                        <option value="conservative">保守型</option>
                        <option value="balanced" selected>平衡型</option>
                        <option value="aggressive">进取型</option>
                    </select>
                </div>
                <div class="form-agreement">
                    <label class="checkbox-container">
                        <input type="checkbox" id="agreeTerms" required>
                        <span class="checkmark"></span>
                        我同意 <a href="#">服务条款</a> 和 <a href="#">隐私政策</a>
                    </label>
                </div>
                <button type="submit" class="btn btn-primary btn-full">注册</button>
            </form>
            <div class="auth-footer">
                <p>已有账户? <a href="login.html">立即登录</a></p>
            </div>
        </div>
    </div>

    <script src="js/main.js"></script>
    <script src="js/auth.js"></script>
    <script>
        document.addEventListener('DOMContentLoaded', function() {
            const registerForm = document.getElementById('registerForm');
            
            registerForm.addEventListener('submit', function(e) {
                e.preventDefault();
                
                const username = document.getElementById('regUsername').value;
                const email = document.getElementById('regEmail').value;
                const password = document.getElementById('regPassword').value;
                const confirmPassword = document.getElementById('regConfirmPassword').value;
                const riskProfile = document.getElementById('riskProfile').value;
                
                // 验证密码是否匹配
                if (password !== confirmPassword) {
                    alert('密码不匹配，请重新输入');
                    return;
                }
                
                // 注册用户
                const result = window.authManager.register({
                    username: username,
                    email: email,
                    password: password,
                    riskProfile: riskProfile
                });
                
                if (result.success) {
                    alert('注册成功！请登录您的账户。');
                    window.location.href = 'login.html';
                } else {
                    alert(result.message);
                }
            });
        });
    </script>
</body>
</html>